/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tr3dtris.game.persistence;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.ho.yaml.Yaml;

/**
 *
 * @author Luciano
 */
public class Options extends AbstractOptions
{
    private DisplayOptions displayOptions;
    private WindowOptions windowOptions;
    private static final String FILE = "data/options.yml";

    public Options()
    {
        this.displayOptions = new DisplayOptions();
        this.windowOptions = new WindowOptions();
    }

    @Override
    public void loadDefaults()
    {
        this.getDisplayOptions().loadDefaults();
        this.getWindowOptions().loadDefaults();
    }

    /**
     * @return the displayOptions
     */
    public DisplayOptions getDisplayOptions() {
        return displayOptions;
    }

    /**
     * @param displayOptions the displayOptions to set
     */
    public void setDisplayOptions(DisplayOptions displayOptions) {
        this.displayOptions = displayOptions;
    }

    /**
     * @return the windowOptions
     */
    public WindowOptions getWindowOptions() {
        return windowOptions;
    }

    /**
     * @param windowOptions the windowOptions to set
     */
    public void setWindowOptions(WindowOptions windowOptions) {
        this.windowOptions = windowOptions;
    }

    public void save()
    {
        try {
            Yaml.dump(this, new File(FILE));
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Options.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static Options load()
    {
        Options options = null;
        try {
            options = (Options) Yaml.load(new File(FILE));
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Options.class.getName()).log(Level.SEVERE, null, ex);
        }
        return options;
    }

}
